<!DOCTYPE html>
<html lang=zh-CN>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="google-site-verification" content="xBT4GhYoi5qRD5tr338pgPM5OWHHIDR6mNg1a3euekI" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta property="og:description" content="samuel-24276的博客">
    <meta property="og:type" content="website">
    <meta name="description" content="samuel-24276的博客">
    <meta name="keyword"  content="aircloud">
    <link rel="shortcut icon" href="/myblog/img/favicon.ico">

    <title>
        
        Xcopy - samuel-24276的博客 | samuel-24276&#39;s Blog
        
    </title>

    <!-- Custom CSS -->
    
<link rel="stylesheet" href="/myblog/css/aircloud.css">

    
<link rel="stylesheet" href="/myblog/css/gitment.css">

    <!--<link rel="stylesheet" href="https://imsun.github.io/gitment/style/default.css">-->
    <link href="//at.alicdn.com/t/font_620856_28hi1hpxx24.css" rel="stylesheet" type="text/css">
    <!-- ga & ba script hoook -->
    <script></script>
<meta name="generator" content="Hexo 7.1.1"></head>

<body>

<div class="site-nav-toggle" id="site-nav-toggle">
    <button>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
        <span class="btn-bar"></span>
    </button>
</div>

<div class="index-about">
    <i> Like what you do, do what you like </i>
</div>

<div class="index-container">
    
    <div class="index-left">
        
<div class="nav" id="nav">
    <div class="avatar-name">
        <div class="avatar ">
            <img src="/myblog/img/avatar.jpg" />
        </div>
        <div class="name">
            <i>samuel-24276</i>
        </div>
    </div>
    <div class="contents" id="nav-content">
        <ul>
            <li >
                <a href="/myblog/">
                    <i class="iconfont icon-shouye1"></i>
                    <span>主页</span>
                </a>
            </li>
            <li >
                <a href="/myblog/tags">
                    <i class="iconfont icon-biaoqian1"></i>
                    <span>标签</span>
                </a>
            </li>
            <li >
                <a href="/myblog/archives">
                    <i class="iconfont icon-guidang2"></i>
                    <span>存档</span>
                </a>
            </li>
            <li >
                <a href="/myblog/collect/">
                    <i class="iconfont icon-shoucang1"></i>
                    <span>收藏</span>
                </a>
            </li>
            <li >
                <a href="/myblog/about/">
                    <i class="iconfont icon-guanyu2"></i>
                    <span>关于</span>
                </a>
            </li>
            
            <li>
                <a id="search">
                    <i class="iconfont icon-sousuo1"></i>
                    <span>搜索</span>
                </a>
            </li>
            
        </ul>
    </div>
    
        <div id="toc" class="toc-article">
    <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#1-Xcopy%E5%8F%82%E6%95%B0%E4%BB%8B%E7%BB%8D"><span class="toc-text">1.Xcopy参数介绍</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2-Xcopy%E5%91%BD%E4%BB%A4%E5%AE%9E%E4%BE%8B%E4%BB%8B%E7%BB%8D"><span class="toc-text">2.Xcopy命令实例介绍</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#2-1-%E6%9C%AC%E6%9C%BA%E5%A4%8D%E5%88%B6%E6%96%87%E4%BB%B6%E6%88%96%E6%96%87%E4%BB%B6%E5%A4%B9%E7%9A%84%E5%AE%9E%E4%BE%8B"><span class="toc-text">2.1.本机复制文件或文件夹的实例</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2-%E5%9C%A8%E5%B1%80%E5%9F%9F%E7%BD%91%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="toc-text">2.2.在局域网中的应用实例</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-3-%E7%BB%93%E5%90%88-d%E6%A0%87%E7%AD%BE%EF%BC%8C%E5%AE%9E%E7%8E%B0%E5%8F%AA%E5%A4%8D%E5%88%B6%E6%AF%94%E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%E6%96%B0%E7%9A%84%E6%96%87%E4%BB%B6"><span class="toc-text">2.3.结合&#x2F;d标签，实现只复制比目标文件新的文件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-4-%E7%A7%BB%E5%8A%A8A%E7%9B%AE%E5%BD%95%E7%9A%84%E6%89%80%E6%9C%89%E6%96%87%E4%BB%B6%E5%88%B0B%E7%9B%AE%E5%BD%95"><span class="toc-text">2.4.移动A目录的所有文件到B目录</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-5-xcopy-%E6%8E%92%E9%99%A4%E6%96%87%E4%BB%B6%E6%8B%B7%E8%B4%9D"><span class="toc-text">2.5.xcopy 排除文件拷贝</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-6-xcopy%E4%B8%8EEXCLUDE%E5%8F%82%E6%95%B0%E7%9A%84%E7%94%A8%E6%B3%95"><span class="toc-text">2.6.xcopy与EXCLUDE参数的用法</span></a></li></ol></li></ol>
</div>
    
</div>


<div class="search-field" id="search-field">
    <div class="search-bg" id="search-bg"></div>
    <div class="search-container">
        <div class="search-input">
            <span id="esc-search"> <i class="icon-fanhui iconfont"></i></span>
            <input id="search-input"/>
            <span id="begin-search">搜索</span>
        </div>
        <div class="search-result-container" id="search-result-container">

        </div>
    </div>
</div>

        <div class="index-about-mobile">
            <i> Like what you do, do what you like </i>
        </div>
    </div>
    
    <div class="index-middle">
        <!-- Main Content -->
        


<div class="post-container">
    <div class="post-title">
        Xcopy
    </div>

    <div class="post-meta">
        <span class="attr">发布于：<span>2020-12-07 20:44:18</span></span>
        
        <span class="attr">标签：/
        
        <a class="tag" href="/myblog/tags/#工具" title="工具">工具</a>
        <span>/</span>
        
        
        </span>
        <span class="attr">访问：<span id="busuanzi_value_page_pv"></span>
</span>
</span>
    </div>
    <div class="post-content no-indent">
        <p><a target="_blank" rel="noopener" href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy">xcopy | Microsoft Learn</a></p>
<p>XCOPY是COPY的扩展，可以把指定的目录连文件和目录结构一并拷贝，但不能拷贝系统文件；使用时源盘符、源目标路径名、源文件名至少指定一个；选用&#x2F;S时对源目录下及其子目录下的所有文件进行COPY。除非指定&#x2F;E参数，否则&#x2F;S不会拷贝空目录，若不指定&#x2F;S参数，则XCOPY只拷贝源目录本身的文件，而不涉及其下的子目录；选用&#x2F;V参数时，对的拷贝的扇区都进行较验，但速度会降低。</p>
<blockquote>
<p>qt的pro配置文件中也可添加各种编译前后的操作及配置，主要通过 QMAKE_POST_LINK和QMAKE_PRE_LINK；</p>
<p>QMAKE_POST_LINK表示编译后执行内容</p>
<p>QMAKE_PRE_LINK表示编译前执行内容</p>
<p>他们支持的函数以及写法，可以在QtCreator的帮助中搜索qmake Function 查看详情说明（QT的帮助文档是我见过最详细的使用文档）；</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">&gt;</span><span class="language-bash">QMAKE_POST_LINK += \</span></span><br><span class="line"><span class="language-bash">&gt;&amp;&amp; xcopy /y /c /h /r /s /i $<span class="variable">$shell_path</span>($<span class="variable">$PWD</span>/stamps) $<span class="variable">$shell_path</span>($<span class="variable">$DESTDIR</span>/../stamps)</span></span><br></pre></td></tr></table></figure>
</blockquote>
<p>我们不可数典忘祖，该学习的还是要学习，不该忘记的还是不能忘记，尤其是DOS批处理命令，在开发软件或项目的时候，都离不开这些基本的原始的命令。本文，我们来学习Xcopy的参数及实例</p>
<h1 id="1-Xcopy参数介绍"><a href="#1-Xcopy参数介绍" class="headerlink" title="1.Xcopy参数介绍"></a>1.Xcopy参数介绍</h1><p>命令格式：XCOPY source [destination] 一堆可选的参数<br>参数介绍<br>source 指定要复制的文件。<br>destination 指定新文件的位置和&#x2F;或名称。</p>
<ul>
<li><p>&#x2F;A 只复制有存档属性集的文件， 但不改变属性。</p>
</li>
<li><p>&#x2F;M 只复制有存档属性集的文件， 并关闭存档属性。</p>
</li>
<li><p>&#x2F;D:m-d-y <strong>复制在指定日期或指定日期以后改变的文件</strong>。如果没有提供日期，只复制那些源时间比目标时间新的文件。</p>
</li>
<li><p>&#x2F;EXCLUDE:file1[+file2][+file3]…</p>
<p>指定含有字符串(filen)的文件列表。如果有任何字符串与要被复制的文件的绝对路径相符，那个文件将不会得到复制。<br>例如，指定如 \obj\ 或 .obj 的字符串会排除目录 obj 下面的所有文件或带有 .obj 扩展名的文件。</p>
</li>
<li><p>&#x2F;P 创建每个目标文件前提示。</p>
</li>
<li><p>&#x2F;S <strong>复制目录和子目录，除了空的。</strong></p>
</li>
<li><p>&#x2F;E <strong>复制目录和子目录，包括空的</strong>。 与 &#x2F;S &#x2F;E 相同。可以用来修改 &#x2F;T。</p>
</li>
<li><p>&#x2F;V 验证每个新文件。</p>
</li>
<li><p>&#x2F;W 提示您在复制前按键。</p>
</li>
<li><p>&#x2F;C <strong>即使有错误，也继续复制</strong>。</p>
</li>
<li><p>&#x2F;I <strong>如果目标不存在，又在复制一个以上的文件， 则假定目标一定是一个目录</strong>。</p>
</li>
<li><p>&#x2F;Q 复制时不显示文件名。</p>
</li>
<li><p>&#x2F;F 复制时显示完整的源和目标文件名。</p>
</li>
<li><p>&#x2F;L 显示要复制的文件。</p>
</li>
<li><p>&#x2F;G 允许将没有经过加密的文件复制到不支持加密的目标。</p>
</li>
<li><p>&#x2F;H <strong>也复制隐藏和系统文件</strong>。</p>
</li>
<li><p>&#x2F;R <strong>改写只读文件</strong>。</p>
</li>
<li><p>&#x2F;T <strong>创建目录结构，但不复制文件。不包括空目录或子目录</strong>。&#x2F;T &#x2F;E 包括空目录和子目录。</p>
</li>
<li><p>&#x2F;U 只复制已经存在于目标中的文件。</p>
</li>
<li><p>&#x2F;K <strong>复制属性。一般的 Xcopy 会重设只读属性</strong>。</p>
</li>
<li><p>&#x2F;N 用生成的短名复制。</p>
</li>
<li><p>&#x2F;O 复制文件所有权和 ACL 信息。</p>
</li>
<li><p>&#x2F;X 复制文件审核设置(隐含 &#x2F;O)。</p>
</li>
<li><p>&#x2F;Y <strong>禁止提示以确认改写一个现存目标文件</strong>。</p>
</li>
<li><p>&#x2F;-Y 导致提示以确认改写一个现存目标文件。</p>
</li>
<li><p>&#x2F;Z 用重新启动模式复制网络文件。</p>
</li>
</ul>
<h1 id="2-Xcopy命令实例介绍"><a href="#2-Xcopy命令实例介绍" class="headerlink" title="2.Xcopy命令实例介绍"></a>2.Xcopy命令实例介绍</h1><h2 id="2-1-本机复制文件或文件夹的实例"><a href="#2-1-本机复制文件或文件夹的实例" class="headerlink" title="2.1.本机复制文件或文件夹的实例"></a>2.1.本机复制文件或文件夹的实例</h2><blockquote>
<p>Xcopy d:\UpdateFiles e:\123 &#x2F;s &#x2F;e &#x2F;y</p>
</blockquote>
<p>　　命令解释：将D盘的UpdateFiles文件夹中包含的所有东西，全部复制到E盘的123文件夹内；&#x2F;s &#x2F;e &#x2F;y　参数说明：在复制文件的同时也复制空目录或子目录，如果目标路径已经有相同文件了，使用覆盖方式而不进行提示。</p>
<h2 id="2-2-在局域网中的应用实例"><a href="#2-2-在局域网中的应用实例" class="headerlink" title="2.2.在局域网中的应用实例"></a>2.2.在局域网中的应用实例</h2><blockquote>
<p>Xcopy \192.168.0.168\UpdateFiles e:\123 &#x2F;s &#x2F;e &#x2F;y</p>
</blockquote>
<p>　　命令解释：将192.168.0.168这台计算机的名称为UpdateFiles的文件夹内的所有东西，全部复制到本机的e:\123 文件夹；参数说明：在复制文件的同时也复制空目录或子目录，如果目标路径已经有相同文件了，使用覆盖方式而不进行提示。</p>
<h2 id="2-3-结合-d标签，实现只复制比目标文件新的文件"><a href="#2-3-结合-d标签，实现只复制比目标文件新的文件" class="headerlink" title="2.3.结合&#x2F;d标签，实现只复制比目标文件新的文件"></a>2.3.结合&#x2F;d标签，实现只复制比目标文件新的文件</h2><p>假如现在c:\a文件夹下的所有文件和d:\a下的文件相同（修改日期及内容）</p>
<p>c:\a下的一个文件被别人修改了或者添加了一个文件！<br>能否写个bat，判断一下c:\a文件夹下的每个文件的最后修改日期是不是在前两天内！如果是，则复制到d:\a下的相应目录（要是原来有，则覆盖），如果不是，则不复制了.</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">@<span class="built_in">echo</span> off </span><br><span class="line"><span class="built_in">echo</span> y|xcopy c:\a /d /e /r /k d:\a\ </span><br><span class="line">pause</span><br></pre></td></tr></table></figure>

<p>经测试<strong>如果目标文件与源文件相同则不复制。确实一定程度了减少了对硬盘的读写</strong>。</p>
<h2 id="2-4-移动A目录的所有文件到B目录"><a href="#2-4-移动A目录的所有文件到B目录" class="headerlink" title="2.4.移动A目录的所有文件到B目录"></a>2.4.移动A目录的所有文件到B目录</h2><p> 移动A目录的所有文件到B目录，且保留A目录的目录结构；如果A下面有子目录，则在B中也创建相同目录，并把对应目录的文件移动到B的相同目录结构位置；（不移动系统文件和隐藏文件）</p>
<figure class="highlight dos"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">@<span class="built_in">echo</span> off</span><br><span class="line"><span class="comment">rem 复制指定目录的目录结构到目标目录，并移动的文件到目标目录，且保留目录结构(空目录也复制)，不保留系统文件和隐藏文件</span></span><br><span class="line"><span class="built_in">set</span> ObjPath=\\<span class="number">192</span>.<span class="number">168</span>.<span class="number">1</span>.<span class="number">186</span>\Temp Files\技术部\BPD\sourceFiles\ZOFUND</span><br><span class="line"><span class="built_in">set</span> DestPath=E:\EastFax\FFPsourceFiles\sourceFiles\ZOFUND</span><br><span class="line"><span class="built_in">set</span> DestExt=* </span><br><span class="line"><span class="built_in">xcopy</span> /e /c /y &quot;<span class="variable">%ObjPath%</span>\<span class="variable">%DestExt%</span>&quot; &quot;<span class="variable">%DestPath%</span>&quot;</span><br><span class="line"><span class="built_in">del</span> /a /s /q /f &quot;<span class="variable">%ObjPath%</span>\&quot;</span><br></pre></td></tr></table></figure>

<h2 id="2-5-xcopy-排除文件拷贝"><a href="#2-5-xcopy-排除文件拷贝" class="headerlink" title="2.5.xcopy 排除文件拷贝"></a>2.5.xcopy 排除文件拷贝</h2><figure class="highlight mel"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br></pre></td><td class="code"><pre><span class="line">@echo off</span><br><span class="line">::xcopy /y /s /e /I /exclude:uncopy.txt E:\NetWorkCMDA\CMDA0418\Portals\<span class="number">0</span> E:\Mu\Portals\<span class="number">0</span></span><br><span class="line">::xcopy /y /s /e /I /exclude:uncopy.txt C:\Docume~<span class="number">1</span>\wangchao\桌面\MyTest C:\Docume~<span class="number">1</span>\wangchao\桌面\aaa</span><br><span class="line">echo 返回默认情况下应用程序存储数据的位置=%APPDATA%</span><br><span class="line">echo 返回当前目录字符串=%CD%</span><br><span class="line">echo 返回计算机的名称=%COMPUTERNAME% </span><br><span class="line">echo 返回命令行解释器可执行程序的准确路径=%COMSPEC% </span><br><span class="line">echo 返回当前登录的用户的名称=%USERNAME%</span><br><span class="line">echo 返回包含用户帐户的域的名称=%USERDOMAIN%</span><br><span class="line">echo 返回当前用户的配置文件的位置=%USERPROFILE%</span><br><span class="line">set myExist=%windir%\TestUncopy</span><br><span class="line">set myCommand=%windir%\TestUncopy&amp;echo TestUncopy</span><br><span class="line"><span class="keyword">if</span> not exist %myExist% mkdir %myCommand%</span><br><span class="line"> </span><br><span class="line">set myExist1=%windir%\TestUncopy\a</span><br><span class="line">set myCommand1=%windir%\TestUncopy\a&amp;echo TestUncopy\a</span><br><span class="line"><span class="keyword">if</span> not exist %myExist1% mkdir %myCommand1%</span><br><span class="line"> </span><br><span class="line">set myExist2=%windir%\TestUncopy\aa</span><br><span class="line">set myCommand2=%windir%\TestUncopy\aa&amp;echo TestUncopy\aa</span><br><span class="line"><span class="keyword">if</span> not exist %myExist2% mkdir %myCommand2%</span><br><span class="line"> </span><br><span class="line">set myExist3=%windir%\TestUncopy\a\b</span><br><span class="line">set myCommand3=%windir%\TestUncopy\a\b&amp;echo TestUncopy\a\b</span><br><span class="line"><span class="keyword">if</span> not exist %myExist3% mkdir %myCommand3%</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">set myExist4=%windir%\TestUncopySource</span><br><span class="line">set myCommand4=%windir%\TestUncopySource&amp;echo TestUncopySource</span><br><span class="line"><span class="keyword">if</span> not exist %myExist4% mkdir %myCommand4%</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line">set myExist5=%windir%\TestUncopy\aaa</span><br><span class="line">set myCommand5=%windir%\TestUncopy\aaa&amp;echo TestUncopy\aaa</span><br><span class="line"><span class="keyword">if</span> not exist %myExist5% mkdir %myCommand5%</span><br><span class="line"> </span><br><span class="line">set copyFile=%windir%\<span class="keyword">system</span>\COMMDLG.DLL</span><br><span class="line"><span class="keyword">if</span> not exist %myExist1%\m1.dll copy  %copyFile% %myExist1% /y</span><br><span class="line"><span class="keyword">if</span> not exist %myExist2%\m2.dll copy  %copyFile% %myExist2% /y</span><br><span class="line"><span class="keyword">if</span> not exist %myExist3%\m3.dll copy  %copyFile% %myExist3% /y</span><br><span class="line"><span class="keyword">if</span> not exist %myExist5%\m5.dll copy  %copyFile% %myExist5% /y</span><br><span class="line"> </span><br><span class="line"><span class="keyword">if</span> not exist %myExist1%\m1.dll ren  %myExist1%\COMMDLG.DLL m1.dll</span><br><span class="line"><span class="keyword">if</span> not  exist %myExist2%\m2.dll ren  %myExist2%\COMMDLG.DLL m2.dll</span><br><span class="line"><span class="keyword">if</span> not  exist %myExist3%\m3.dll ren  %myExist3%\COMMDLG.DLL m3.dll</span><br><span class="line"><span class="keyword">if</span> not  exist %myExist5%\m5.dll ren  %myExist5%\COMMDLG.DLL m5.dll</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"><span class="keyword">if</span> not exist %myExist5%\txt1.exe copy  %windir%\system32\notepad.exe %myExist5% /y</span><br><span class="line"><span class="keyword">if</span> not exist %myExist5%\txt1.exe ren  %myExist5%\notepad.exe txt1.exe</span><br><span class="line"> </span><br><span class="line"><span class="keyword">if</span> not exist %myExist5%\txt2.exe copy  %windir%\system32\notepad.exe %myExist5% /y</span><br><span class="line"><span class="keyword">if</span> not exist %myExist5%\txt2.exe ren  %myExist5%\notepad.exe txt2.exe</span><br><span class="line"> </span><br><span class="line"><span class="keyword">if</span> not exist %myExist5%\txt3.exe copy  %windir%\system32\notepad.exe %myExist5% /y</span><br><span class="line"><span class="keyword">if</span> not exist %myExist5%\txt3.exe ren  %myExist5%\notepad.exe txt3.exe</span><br><span class="line"> </span><br><span class="line">set OutFile=uncopy.txt</span><br><span class="line">::MyDir=\aa\ 排除的文件夹</span><br><span class="line">::MySubDir=\a\b\ 排除的子文件夹</span><br><span class="line">::MyFile=m3.dll 排除的文件</span><br><span class="line">::set MyFile1=.exe 排除的类型文件</span><br><span class="line">set MyDir=\aa\</span><br><span class="line">set MySubDir=\a\b\</span><br><span class="line">set MyFile=m3.dll</span><br><span class="line">set MyFile1=.exe</span><br><span class="line">echo %MyDir% &gt;uncopy.txt</span><br><span class="line">echo %MySubDir% &gt;&gt;uncopy.txt</span><br><span class="line">echo %MyFile% &gt;&gt;uncopy.txt</span><br><span class="line">echo %MyFile1% &gt;&gt;uncopy.txt</span><br><span class="line">xcopy /y /s /e /I /exclude:uncopy.txt %windir%\TestUncopy %windir%\TestUncopySource</span><br><span class="line"> </span><br><span class="line">::<span class="keyword">if</span> exist %windir%\TestUncopy del %windir%\TestUncopy /s /q&amp;rd %windir%\TestUncopy /s /q &amp;echo del_rd %windir%\TestUncopy</span><br><span class="line">::<span class="keyword">if</span> exist %windir%\TestUncopySource del %windir%\TestUncopySource /s /q&amp;rd %windir%\TestUncopySource /s /q &amp;echo del_rd %windir%\TestUncopySource</span><br><span class="line">::del uncopy.txt</span><br><span class="line"> </span><br><span class="line">start %myExist%</span><br><span class="line">start %myExist4%</span><br><span class="line"> </span><br><span class="line">echo 是否删除(Y/N)</span><br><span class="line">set /p shuru=</span><br><span class="line">::<span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==y (echo %shuru:~<span class="number">0</span>,<span class="number">1</span>%&amp;goto del)</span><br><span class="line">::<span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==Y (echo %shuru:~<span class="number">0</span>,<span class="number">1</span>%&amp;goto del)</span><br><span class="line">::<span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==n (echo %shuru:~<span class="number">0</span>,<span class="number">1</span>%&amp;goto End)</span><br><span class="line">::<span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==N (echo %shuru:~<span class="number">0</span>,<span class="number">1</span>%&amp;goto End)  </span><br><span class="line"><span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==y (cls&amp;goto del)</span><br><span class="line"><span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==Y (cls&amp;goto del)</span><br><span class="line"><span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==n (cls&amp;goto End)</span><br><span class="line"><span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==N (cls&amp;goto End)  </span><br><span class="line"><span class="keyword">pause</span></span><br><span class="line">:del</span><br><span class="line"><span class="keyword">if</span> exist %windir%\TestUncopy del %windir%\TestUncopy /s /q&amp;rd %windir%\TestUncopy /s /q &amp;echo del_rd %windir%\TestUncopy</span><br><span class="line"><span class="keyword">if</span> exist %windir%\TestUncopySource del %windir%\TestUncopySource /s /q&amp;rd %windir%\TestUncopySource /s /q &amp;echo del_rd %windir%\TestUncopySource</span><br><span class="line"><span class="keyword">if</span> exist uncopy.txt del uncopy.txt</span><br><span class="line">:End</span><br><span class="line">echo.&amp; ::换行</span><br><span class="line">echo 操作已经完成</span><br><span class="line">timeout /t <span class="number">3</span> /nobreak</span><br><span class="line">cls</span><br><span class="line"> </span><br><span class="line">echo 是否重新调用(Y/N)--Y:调用 N:退出</span><br><span class="line">set /p shuru=</span><br><span class="line"><span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==y (cls&amp;goto MyCall)</span><br><span class="line"><span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==Y (cls&amp;goto MyCall)</span><br><span class="line"><span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==n (cls&amp;goto EndExit)</span><br><span class="line"><span class="keyword">if</span> %shuru:~<span class="number">0</span>,<span class="number">1</span>%==N (cls&amp;goto EndExit) </span><br><span class="line">:EndExit</span><br><span class="line">exit </span><br><span class="line">:MyCall</span><br><span class="line">uncopy.bat</span><br><span class="line"> </span><br><span class="line"><span class="keyword">pause</span></span><br></pre></td></tr></table></figure>

<h2 id="2-6-xcopy与EXCLUDE参数的用法"><a href="#2-6-xcopy与EXCLUDE参数的用法" class="headerlink" title="2.6.xcopy与EXCLUDE参数的用法"></a>2.6.xcopy与EXCLUDE参数的用法</h2><p><strong>示例一：例如,我要将”WebAppBuytoy”目录备份一份到”WebAppBuytoy_bak”,但要排除其下面的</strong><br><strong>“WebAppBuytoy\product\ProdImages”子目录,因为它太大且没有变化没有必要备份.</strong></p>
<p>步骤一,新建一个文本文件叫”EXCLUDE.txt”,内容如下:</p>
<blockquote>
<p>product\ProdImages</p>
</blockquote>
<p>步骤二,命令(包含子目录,不提示覆盖):</p>
<blockquote>
<p>xcopy WebAppBuytoy WebAppBuytoy_bak &#x2F;e &#x2F;EXCLUDE:EXCLUDE.txt &#x2F;y</p>
</blockquote>
<p><strong>示例二： 发布.net的Web项目批处理</strong></p>
<p>deploy_web.cmd</p>
<figure class="highlight dos"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">xcopy</span> G:\WebSites\BuytoySolutionV2\WebAppBuytoy web /EXCLUDE:web_exclude.txt /i /e /y</span><br><span class="line"><span class="comment">@rem 将排除的*.css文件补回</span></span><br><span class="line"><span class="built_in">xcopy</span> G:\WebSites\BuytoySolutionV2\WebAppBuytoy\App_Themes web\App_Themes /i /e /y</span><br><span class="line">@<span class="built_in">pause</span></span><br></pre></td></tr></table></figure>

<p>web_exclude.txt:</p>
<blockquote>
<p>.cs<br>.vb<br>.pdb<br>.csproj<br>.csproj.user<br>.Publish.xml<br>.___<br>.cmd<br>.rar<br>\App_Themes\Theme1<br>\App_Themes\Theme1<br>\obj<br>\obj<br>\Properties<br>\Properties<br>\App_Data<br>\App_Classes\</p>
</blockquote>
<p><strong>示例三： 发布.net的Web项目批处理，但排除商品图片目录，因为它太大且不常更新，</strong></p>
<p>重复使用上面那个排除文件“web_exclude.txt”，再加一个排除商品图片的排除文件<br>“web_exclude_prodImages.txt”，这样要在一个命令中使用多个排除文件列表，用到加号“+”：</p>
<p>deploy_web_排除商品图片.cmd</p>
<figure class="highlight dos"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">xcopy</span> G:\WebSites\BuytoySolutionV2\WebAppBuytoy web </span><br><span class="line">/EXCLUDE:web_exclude.txt+web_exclude_prodImages.txt /i /e /y</span><br><span class="line"><span class="comment">@rem 将排除的*.css文件补回</span></span><br><span class="line"><span class="built_in">xcopy</span> G:\WebSites\BuytoySolutionV2\WebAppBuytoy\App_Themes web\App_Themes /i /e /y</span><br><span class="line">@<span class="built_in">pause</span></span><br></pre></td></tr></table></figure>

<p>web_exclude_prodImages.txt</p>
<blockquote>
<p>\product\ProdImages<br>\product\ProdImages\</p>
</blockquote>
<hr>

        
            <div class="donate-container">
    <div class="donate-button">
        <button id="donate-button">赞赏</button>
    </div>
    <div class="donate-img-container hide" id="donate-img-container">
        <img id="donate-img" src="" data-src="/myblog/img/donate.jpg">
        <p> 感谢鼓励 </p>
    </div>
</div>
        
        <br />
        <div id="comment-container">
        </div>
        <div id="disqus_thread"></div>
        <div id="lv-container"></div>
        <div class="giscus"></div>
    </div>
</div>

    </div>
</div>


<footer class="footer">
    <ul class="list-inline text-center">
        
        

        

        

        
        <li>
            <a target="_blank"  href="https://github.com/samuel-24276">
                            <span class="fa-stack fa-lg">
                                <i class="iconfont icon-github"></i>
                            </span>
            </a>
        </li>
        

        

    </ul>
    
    <p>
        <span>/</span>
        
        <span><a target="_blank" rel="noopener" href="https://github.com/samuel-24276">samuel-24276&#39;s Page</a></span>
        <span>/</span>
        
        <span><a target="_blank" rel="noopener" href="https://beian.miit.gov.cn/">北京-未备案</a></span>
        <span>/</span>
        
        <span><a href="#">返回顶部</a></span>
        <span>/</span>
        
    </p>
    
    <p>
        <span id="busuanzi_container_site_pv">
            <span id="busuanzi_value_site_pv"></span>PV
        </span>
        <span id="busuanzi_container_site_uv">
            <span id="busuanzi_value_site_uv"></span>UV
        </span>
        Created By <a target="_blank" rel="noopener" href="https://hexo.io/">Hexo</a>  Theme <a target="_blank" rel="noopener" href="https://github.com/aircloud/hexo-theme-aircloud">AirCloud</a></p>
</footer>




</body>

<script>
    // We expose some of the variables needed by the front end
    window.hexo_search_path = "search.json"
    window.hexo_root = "/myblog/"
    window.isPost = true
</script>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>

<script src="/myblog/js/index.js"></script>

<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>






    <script type="text/javascript">
       (function() {
           if (typeof LivereTower === 'function') { return; }

           var j, d = document.getElementById('lv-container');

           d.setAttribute('data-id','city');
           d.setAttribute('data-uid' , 'MTAyMC80OTA5OC8yNTU5Mw==');

           j = document.createElement('script');
           j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
           j.async = true;

           d.appendChild(j);
       })();
    </script>
    <noscript>为正常使用来必力评论功能请激活JavaScript</noscript>
    </div>

</html>
